/**
 * @author: Miss.杨
 * @date: 2025年3月16日 16:50:09
 * @description: 
 */
package com.sheepone.monitor.audit;

import com.sheepone.audit.client.AuditLogMessageContext;
import com.sheepone.monitor.audit.core.entities.AuditLogMessage;
import com.sheepone.monitor.client.AbstractMonitorClient;
import com.sheepone.monitor.client.config.MonitorClientConfig;
import com.sheepone.monitor.codec.SheeponePackage;
import com.sheepone.monitor.enums.SerializationAlgorithmsEnum;
import com.sheepone.monitor.enums.SheeponePackageTypeEnum;

/**
 * @author: Miss.杨
 * @date: 2025年3月16日 16:50:09
 * @description:
 */
public abstract class AuditMonitorClient<C extends MonitorClientConfig, I extends AuditMonitorClientChannelInitializer>
        extends AbstractMonitorClient<C, I> {

    public AuditMonitorClient(C config) {
        super(config);
    }

    public void send(AuditLogMessage message) {
        SheeponePackage sp = new SheeponePackage();
        sp.setSerialization(SerializationAlgorithmsEnum.PROTOBUF);
        sp.setContent(message.toRequest().toByteArray());
        sp.setType(SheeponePackageTypeEnum.AUDIT_LOG_REQUEST);
        this.writeAndFlush(sp);
    }

    public void send() {
        send(AuditLogMessageContext.getMessage());
    }

}
